﻿using DongFangGuoKai.TaskPlatform.Commn.ApiModule;
using DongFangGuoKai.TaskPlatform.Commn.Attributes;
using DongFangGuoKai.TaskPlatform.Commn.NoticeModule;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DongFangGuoKai.TaskPlatform.WebApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class RFIDController : ControllerBase
    {
        private IConfiguration _configuration;

        public RFIDController(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        [AutowiredProperty]
        public IApiClient _apiClient { get; set; }

        [AutowiredProperty]
        public IHttpContextAccessor _httpContextAccessor { get; set; }

        [HttpGet]
        [Route("GetRFIDToken")]
        public IActionResult GetRFIDToken()
        {

            var headers = _httpContextAccessor.HttpContext.Request.Headers;
            var t = headers["Host"];
            


            var str = _apiClient.GetAuthToken();

            return Ok(str);
        }


        [HttpPost]
        [Route("GetRFIDToken")]
        public void Test()
        {
            var headers = _httpContextAccessor.HttpContext.Request.Headers;
            var t = headers["Host"];
            foreach (var item in headers)
            {
                Console.WriteLine(item.Key+":"+item.Value);
            }

            Console.WriteLine("----------------------------");
        }
    }
}
